package com.betterwood.dragon.dao.enhances.impl;

import com.betterwood.dragon.dao.common.MongoDBUtils;
import com.betterwood.dragon.dao.enhances.SysUserMongoRepository;
import com.betterwood.dragon.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;

import java.lang.reflect.InvocationTargetException;


/**
 * @author zhengyanhua
 * @create 2021-03-16 16:35
 */
public class SysUserMongoRepositoryImpl implements SysUserMongoRepository {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public void updateSysUsertest(SysUser sysUser) throws InvocationTargetException,IllegalAccessException,NoSuchMethodException {
        Query query= MongoDBUtils.getQuery(sysUser.getId());
        Update update= MongoDBUtils.getUpdate(sysUser);
        mongoTemplate.updateFirst(query,update , SysUser.class);
    }
}
